#include <iostream>
#include <regex>
#include <string>

void regular(std::string str)
{
    std::smatch match;//匹配结果

    std::regex pattern("(GET|POST|) (.*)\\?(.*) (HTTP/1\\.[01])(?:\n|\r\n)?");//匹配规则

    bool ret = std::regex_match(str, match, pattern);
    if(ret != true)
    {
        std::cout << "match fail" << std::endl;
        return;
    }
    else
    {
        std::cout << "result:" << std::endl;
        for(auto& e:match)
        {
            std::cout << e << std::endl;
        }
    }
}

int main()
{
    //请求行
    std::string str("GET /lib/login?user=ly&pass=123456 HTTP/1.1");

    regular(str);

    return 0;
}